home *** CD-ROM | disk | FTP | other *** search
- /*********
- (c) AURODREPH Productions 04/1996
- **********/
-
- #include "io.h"
- #include "stdlib.h"
- #include "stdio.h"
- #include "conio.h"
- #include "process.h"
- #include "fcntl.h"
- #include "string.h"
- #include "sys\stat.h"
-
- void main (void)
- {
- char Name[13];
- char Target[13];
- unsigned char *Buffer;
- int Handler, Handler1;
- unsigned int Offset;
- unsigned long Length = 0;
- int point, max, trouve, cledec, debmac, decfin;
- int stop,nbr,positcle,nbrmac,i;
-
- clrscr();
- printf (" ******************************************************************\n");
- printf (" * *\n");
- printf (" * DECRYPT WORD 6.0 MACROS saved *\n");
- printf (" * with the option Execute-only *\n");
- printf (" * *\n");
- printf (" * *\n");
- printf (" * --- ,This file works only with files < 32 Ko. ---- *\n");
- printf (" * <*****}===============- *\n");
- printf (" * (z) ' AURODREPH Productions 04/1996 *\n");
- printf (" * ver 0.666B *\n");
- printf (" ******************************************************************\n");
- printf ("\n"); printf("\n");
- printf ("Name of the input file = ");
- scanf ("%12s",Name);
- printf ("\n");
- printf ("Name of the output file = ");
- scanf ("%12s",Target);
- printf("\n");
- printf ("Number of crypted macros = ");
- scanf ("%d",&nbrmac);
- printf("\n");
- if (nbrmac > 50 ) {exit (0);}
- Handler = open (Name, O_BINARY | O_RDONLY , S_IREAD);
- if (Handler == -1)
- {printf ("The input file doesn't exist.\n"); exit(0);}
-
- Length = (unsigned long) lseek(Handler, 0, SEEK_END);
- lseek (Handler,0,SEEK_SET);
- Buffer = (unsigned char *) malloc((unsigned) Length);
- if (Buffer == NULL) printf ("Fail memory allocation.\n");
- if (read(Handler, Buffer, (unsigned) Length) != Length)
- {printf ("The size of the file is > 32 ko)\n");
- printf ("Try to remove some macros with WORD....\n");
- exit (0);}
-
- point = 0;
- max = strlen(Name);
- trouve = 1;
- cledec = 0x00;
- debmac = 0x00;
- stop = 0;
- for (i=0; i<max;i++)
- {if ((Name[i]>= 0x61) & (Name[i]<= 0x7A))
- { Name[i] = Name[i] & 0xDF ;}
- };
-
- for (Offset = 0x0000; Offset < Length; Offset++)
- {
- if ((Buffer[Offset] == Name[point]) && (stop !=1))
- {
- for (point = 1; point <= (max-1); point++)
- {if (Buffer [Offset+point] == Name[point])
- { trouve = trouve+1; } }
- else trouve = 1;
- };
- }
- if (trouve == max) {stop = 1;}
- if ((trouve == max) && (Buffer[Offset] == 0x55))
- {cledec = Buffer[Offset+1];
- trouve = 0;
- Buffer [Offset+1] = 0x00;
- positcle = Offset;
- }
- point = 0;
- };
- if (cledec == 0x00)
- {printf (" Don't find the decrypted key... \n"); exit (0);}
- else printf ("Decrypted Key for the macro n 1 = %x \n", cledec);
-
- for (Offset = 0x0000; Offset < Length; Offset++)
- {
- if (Buffer[Offset] == 0xA5)
- {if ((Buffer [Offset+1] == 0xC6) || (Buffer [Offset+1] == 0xC4))
- {if (Buffer [Offset+2] == 0x41)
- {if (Buffer [Offset+4] == cledec)
- {debmac = Offset+3;
- }
- } } } };
- if (debmac == 0x00)
- {for (Offset = 0x0000; Offset < Length; Offset++)
- {
- if (Buffer[Offset] == cledec-1)
- {if (Buffer [Offset+1] == cledec)
- {debmac = Offset; }
- } }; }
- if (debmac == 0x00) { printf (" Don't find the beginning of the macro\n"); exit(0);}
-
-
- for (nbr = 1 ; nbr <= nbrmac ;nbr++)
- {
- if (nbr != 1)
- {
- printf ("\n");
- printf (" I decrypt the macro n %d \n", nbr);
- Offset = positcle+24;
- if (Buffer[Offset] == 0x55)
- {cledec = Buffer [Offset+1];
- Buffer [Offset+1] = 0x00;
- positcle = Offset;
- printf ("Decrypted Key for the macro n %d = %x \n", nbr,cledec);
- }
- else
- {printf (" Don't find the decrypted key ....\n");}
- }
- Offset = debmac;
- point = 0;
- decfin = 1;
- stop = 1;
- printf ( " I work ");
- do
- { if (stop == 400) {printf ("."); stop = 1 ;}
- Buffer[Offset+point] ^= cledec ; /* decryptage par XOR */
-
- if (Buffer [Offset+point] == 0x64)
- {Buffer [Offset+point+1] ^= cledec;
- if (Buffer [Offset+point+1] == 0x1a)
- {Buffer [Offset+point+2] ^= cledec;
- if (Buffer [Offset+point+2] == 0x1b)
- {Buffer [Offset+point+3] ^= cledec;
- if (Buffer [Offset+point+3] != 0x64)
- {decfin = 0;
- debmac = Offset+point+3;
- Buffer [Offset+point+3] ^= cledec;
- }
- else
- Buffer [Offset+point+3] ^= cledec;
- }
- else
- Buffer [Offset+point+2] ^= cledec;
- }
- else
- Buffer [Offset+point+1] ^= cledec;
- }
- if ((Offset+point) == Length) {decfin = 0;}
-
- stop = stop + 1;
- point = point + 1;
- }
- while ( ( decfin != 0) );
- printf ("\n");
- printf (" End of decrypting the macro n %d \n", nbr);
- };
-
- _fmode= O_BINARY;
-
- Handler1 = creat(Target, S_IFMT | S_IREAD | S_IWRITE);
- write (Handler1, Buffer,(unsigned) Length);
-
- close (Handler1);
- close (Handler);
- printf ("\n"); printf ("\n");
- printf (" END ... \n");
- printf ("\n");
- printf (" The decrypted file is %s .\n", Target);
- }
-
- - ------------------><--- cut here ------------------------------------
-